package com.chinanet.entry.faultanticipate;

import com.chinanet.audit.DateAudit;
import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "record")
public class Record extends DateAudit implements Serializable {

    @Override
	public String toString() {
		return "Record [id=" + id + ", modelId=" + modelId + ", isDelete=" + isDelete + ", comment=" + comment
				+ ", operations=" + operations + ", branch=" + branch + "]";
	}

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    // 关联Model的流程图
    private String modelId;

    private boolean isDelete;

    private String comment;

    @OneToMany(mappedBy = "record", cascade = CascadeType.ALL,fetch= FetchType.EAGER)
    private List<Operation> operations = new ArrayList<>();

    @JsonIgnore
    @ManyToOne(cascade = CascadeType.MERGE)
    private Branch branch;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getModelId() {
        return modelId;
    }

    public void setModelId(String modelId) {
        this.modelId = modelId;
    }

    public boolean isDelete() {
        return isDelete;
    }

    public void setDelete(boolean delete) {
        isDelete = delete;
    }

    public List<Operation> getOperations() {
        return operations;
    }

    public void setOperations(List<Operation> operations) {
        this.operations = operations;
    }

    public Branch getBranch() {
        return branch;
    }

    public void setBranch(Branch branch) {
        this.branch = branch;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }
}
